global path "G:\My Drive\Dissertation\"	//Percy's path
*global path "C:\Users\jbucheli\Google Drive Streaming\.shortcut-targets-by-id\1EWiHHsz4sWi5eblqcHzRWF03rnGHsxZe\Dissertation"	//Dr. Bucheli's path

cd "$path"
use "STATA DATA Files\Merged data.dta", clear

merge 1:1 CountryName year using "STATA DATA Files\New Variables.dta"
duplicates drop country_id year ,force
drop if CountryName=="Sao Tome and Principe"
drop if CountryName=="Guinea-Bissau"
 drop _merge
 
 merge 1:1 CountryName  year using "G:\My Drive\Dissertation\STATA DATA Files\New_Variables_1.dta"
 drop if CountryName=="Sao Tome and Principe"
 drop if CountryName=="Guinea-Bissau"
 drop if CountryName=="Benin"
 duplicates drop country_id year ,force
 drop _merge
 
 merge 1:1 CountryName year using "G:\My Drive\Dissertation\STATA DATA Files\New Variables 2.dta", force
 drop if CountryName=="Guinea-Bissau"
 drop if CountryName=="Benin"
 
 drop _merge
 merge 1:1 CountryName year using "G:\My Drive\Dissertation\STATA DATA Files\New Variables 4.dta"
 drop if CountryName=="Guinea-Bissau"
  drop if CountryName=="Benin"
   drop if CountryName=="Cabo Verde"
 gen female_out_primschool_rate= Children_out_of_sch_primary_fem/100000
 drop if year==2021
 
******Start running synthetic control models
*1) Mozambique and all SSA countries without abortion laws
tsset country_id year

drop if CountryName=="Seychelles"
drop if CountryName=="Somalia"
drop if CountryName=="Zambia"
drop if CountryName=="Eritrea"
drop if CountryName=="Sierra Leone"
drop if CountryName=="South Sudan"
****(Because it has too many missing values)


************** Graphs******************
************************************************

*Adolescent Fertility**
synth2 Adolescent_fertility Adolescent_fertility(1997) Adolescent_fertility(1997) Adolescent_fertility(2002) Adolescent_fertility(2005) GDPpercapita_con_2015(2012)  GDPpercapita_con_2015(2011) Laborforce_part_female_15_24(2011) Laborforce_part_female_15_24(2012) Sch_enroll_Secondary_female Unem_youthfemale Contraceptive_prev_anymethod Contraceptive_prev_modernmethod female_out_primschool_rate,trunit(28) trperiod(2014) unitnames(CountryName) mspeperiod(1997(1)2014) resultsperiod(1997(1)2020) fig

synth_runner Adolescent_fertility Adolescent_fertility(1997) Adolescent_fertility(1997) Adolescent_fertility(2002) Adolescent_fertility(2005) GDPpercapita_con_2015(2012)  GDPpercapita_con_2015(2011) Laborforce_part_female_15_24(2011) Laborforce_part_female_15_24(2012) Sch_enroll_Secondary_female Unem_youthfemale Contraceptive_prev_anymethod Contraceptive_prev_modernmethod female_out_primschool_rate,trunit(28) trperiod(2014)gen_vars

effect_graphs
**Drop Countries with high and low ASMD****
drop if CountryName=="Sudan"
drop if CountryName=="Equatorial Guinea" 
drop if CountryName=="Senegal"
drop if CountryName=="Nigeria"
****N/B: Deleted  more countries manually using Graph editor
single_treatment_graphs

****Not neeeded for this paper 
ereturn list
display (e(pval_joint_post_std)*e(n_pl)+1)/(e(n_pl)+1)
pval_graphs

clear 
**reload variables

*****Total fertility rate**** do more**
synth2 Fertility_rate Fertility_rate(1997) Fertility_rate(2005) Fertility(2010) Fertility_rate(2012) Unemp_female Contraceptive_prev_anymethod  Literacy_rate_adult_total Population_15_64_female Mortality_rate_under_5 Contraceptive_prev_modernmethod Unemp_female(2006) ,trunit(28) trperiod(2014) unitnames(CountryName) mspeperiod(1997(1)2014) resultsperiod(1997(1)2020) fig

synth_runner Fertility_rate Fertility_rate(1997) Fertility_rate(2005) Fertility(2010) Fertility_rate(2012) Unemp_female Contraceptive_prev_anymethod  Literacy_rate_adult_total Population_15_64_female Mortality_rate_under_5 Contraceptive_prev_modernmethod Unemp_female(2006) ,trunit(28) trperiod(2014) gen_vars


effect_graphs
**Drop Countries with high and low ASMD****
drop if CountryName=="Niger"
drop if CountryName=="Chad"
drop if CountryName=="Burundi"
drop if CountryName=="Mauritius"
drop if CountryName=="Botswana"
drop if CountryName=="Lesotho"
drop if CountryName=="Eswatini"
drop if CountryName=="Namibia"
drop if CountryName=="Zimbabwe"
****N/B: Deleted  more countries manually using Graph editor
single_treatment_graphs

****Not neeeded for this paper 
ereturn list
display (e(pval_joint_post_std)*e(n_pl)+1)/(e(n_pl)+1)
pval_graphs


clear 
**reload variables

*****LifeExpectancy at Birth******
synth2 Life_expectancy_atbirth Life_expectancy_atbirth(1998) Life_expectancy_atbirth(2002) Life_expectancy_atbirth(2012)  Fertility_rate Fertility_rate(2009) Contraceptive_prev_anymethod Contraceptive_prev_modernmethod Literacy_rate_adult_total Births_by_skilled_healthstaff  Current_health_expend_gdp GDP_growth Mortality_rate_infant,trunit(28) trperiod(2014) unitnames(CountryName) mspeperiod(1997(1)2014) resultsperiod(1997(1)2020) fig

synth_runner Life_expectancy_atbirth Life_expectancy_atbirth(1998) Life_expectancy_atbirth(2002) Life_expectancy_atbirth(2012)  Fertility_rate Fertility_rate(2009) Contraceptive_prev_anymethod Contraceptive_prev_modernmethod Literacy_rate_adult_total Births_by_skilled_healthstaff  Current_health_expend_gdp GDP_growth Mortality_rate_infant,trunit(28) trperiod(2014) gen_vars

effect_graphs
**Drop Countries with high and low ASMD****
drop if CountryName=="Mauritius"
drop if CountryName=="Rwanda"
drop if CountryName=="Malawi"
drop if CountryName=="Zimbabwe"
drop if CountryName=="Lesotho"
drop if CountryName=="Eswatini"
****deleted  more countries manually using Graph editor
single_treatment_graphs

****Not neeeded for this paper 
ereturn list
display (e(pval_joint_post_std)*e(n_pl)+1)/(e(n_pl)+1)
pval_graphs

clear 
**reload variables

**********Infant Mortality Rate****** 
synth2 Mortality_rate_infant Mortality_rate_infant(1998) Mortality_rate_infant(2012) GDPpercapita_con_2015 GDPpercapita_con_2015(2009) Fertility_rate Fertility_rate(2009) Contraceptive_prev_anymethod Literacy_rate_adult_total health_expenditure_ppp,trunit(28) trperiod(2014) unitnames(CountryName) mspeperiod(1997(1)2014) resultsperiod(1997(1)2020) fig

synth_runner Mortality_rate_infant Mortality_rate_infant(1998) Mortality_rate_infant(2012) GDPpercapita_con_2015 GDPpercapita_con_2015(2009) Fertility_rate Fertility_rate(2009) Contraceptive_prev_anymethod Literacy_rate_adult_total health_expenditure_ppp,trunit(28) trperiod(2014) gen_vars

effect_graphs
**Drop Countries with high and low ASMD****
drop if CountryName=="Mauritius"
drop if CountryName=="Rwanda"
drop if CountryName=="Liberia"
drop if CountryName=="Angola"
drop if CountryName=="Rwanda"
drop if CountryName=="Malawi"
****N/B: Deleted  more countries manually using Graph editor
single_treatment_graphs

****Not neeeded for this paper 
ereturn list
display (e(pval_joint_post_std)*e(n_pl)+1)/(e(n_pl)+1)
pval_graphs

clear 
**reload variables

*****Infant Mortality Under 5 Years****(not aded to paper)
*synth2  Mortality_rate_under_5 Mortality_rate_under_5(1998) Mortality_rate_under_5(2005) Mortality_rate_under_5(2012) GDPpercapita_con_2015 GDPpercapita_con_2015(2009) Fertility_rate Fertility_rate(2009) Fertility_rate(2011) Contraceptive_prev_anymethod Literacy_rate_adult_total GDP_growth health_expenditure_ppp,trunit(28) trperiod(2013) unitnames(CountryName) mspeperiod(1997(1)2013) resultsperiod(1997(1)2020) fig

*synth_runner  Mortality_rate_under_5 Mortality_rate_under_5(1998) Mortality_rate_under_5(2005) Mortality_rate_under_5(2012) GDPpercapita_con_2015 GDPpercapita_con_2015(2009) Fertility_rate Fertility_rate(2009) Fertility_rate(2011) Contraceptive_prev_anymethod Literacy_rate_adult_total GDP_growth health_expenditure_ppp,trunit(28) trperiod(2013) gen_vars

*effect_graphs
*single_treatment_graphs
*ereturn list
*display (e(pval_joint_post_std)*e(n_pl)+1)/(e(n_pl)+1)
*pval_graphs

clear 
**reload variables

****Mortality_rate_adultfemale******

synth2 Mortality_rate_adultfemale  Mortality_rate_adultfemale(1998) Mortality_rate_adultfemale(2012) Literacy_rate_adult_total health_expenditure_current Fertility_rate(1997) Fertility_rate(2000) Fertility_rate(2012) Prevalence_anemia_pregnant_women  GDP_growth Births_by_skilled_healthstaff Number_neonatal_deaths ,trunit(28) trperiod(2014) unitnames(CountryName) mspeperiod(1997(1)2014) resultsperiod(1997(1)2020) fig

synth_runner Mortality_rate_adultfemale  Mortality_rate_adultfemale(1998) Mortality_rate_adultfemale(2012) Literacy_rate_adult_total health_expenditure_current Fertility_rate(1997) Fertility_rate(2000) Fertility_rate(2012) Prevalence_anemia_pregnant_women GDP_growth Births_by_skilled_healthstaff Number_neonatal_deaths ,trunit(28) trperiod(2014)gen_vars

effect_graphs
**Drop Countries with high and low ASMD****
drop if CountryName=="Eswatini"
drop if CountryName=="Lesotho"
drop if CountryName=="Central African Republic"
drop if CountryName=="Zimbabwe"
drop if CountryName=="Mauritania"
drop if CountryName=="Mauritius"
drop if CountryName=="Senegal"
drop if CountryName=="Sudan"


drop if CountryName=="Congo, Rep."
drop if CountryName=="Namibia"

drop if CountryName=="Botswana"
drop if CountryName=="Zambia"
drop if CountryName=="Rwanda"
drop if CountryName=="Malawi"
drop if CountryName=="Benin"
****N/B: Deleted  more countries manually using Graph editor
single_treatment_graphs
****Not neeeded for this paper 
ereturn list
display (e(pval_joint_post_std)*e(n_pl)+1)/(e(n_pl)+1)
pval_graphs

*********GRAPHS*******
 graph save "graph1" "C:\Users\percyt\Desktop\Results\Adolecent Fertility_SCM.gph", replace

   
   
 
 